/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.car.entity;

import com.thinkgem.jeesite.common.utils.DateUtils;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.thinkgem.jeesite.common.persistence.DataEntity;

/**
 * 定位信息Entity
 * @author xiaoqian
 * @version 2018-01-06
 */
public class GpsInfo extends DataEntity<GpsInfo> {
	
	private static final long serialVersionUID = 1L;
	private String simNo;		// sim
	private String plateNo;		// 车牌号
	private String longitude;		// 经度
	private String latitude;		// 纬度
	private String speed;		// 速度
	private String location;		// 对经纬度的地理位置解析
	private String direction;		// 方向,0～359，正北为0，顺时针
	private String alarmStatus;		// 报警位状态
	private String mileage;		// 里程
	private String oilNum;		// 油量
	private String altitude;		// 海拔
	private String status;		// 状态
	private Date sendTime;		// 发送时间
	
	public GpsInfo() {
		super();
	}

	public GpsInfo(String id){
		super(id);
	}

	@Length(min=0, max=64, message="sim长度必须介于 0 和 64 之间")
	public String getSimNo() {
		return simNo;
	}

	public void setSimNo(String simNo) {
		this.simNo = simNo;
	}
	
	@Length(min=0, max=64, message="车牌号长度必须介于 0 和 64 之间")
	public String getPlateNo() {
		return plateNo;
	}

	public void setPlateNo(String plateNo) {
		this.plateNo = plateNo;
	}
	
	@Length(min=0, max=64, message="经度长度必须介于 0 和 64 之间")
	public String getLongitude() {
		return longitude;
	}

	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}
	
	@Length(min=0, max=64, message="纬度长度必须介于 0 和 64 之间")
	public String getLatitude() {
		return latitude;
	}

	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}
	
	@Length(min=0, max=64, message="速度长度必须介于 0 和 64 之间")
	public String getSpeed() {
		return speed;
	}

	public void setSpeed(String speed) {
		this.speed = speed;
	}
	
	@Length(min=0, max=255, message="对经纬度的地理位置解析长度必须介于 0 和 255 之间")
	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}
	
	@Length(min=0, max=11, message="方向,0～359，正北为0，顺时针长度必须介于 0 和 11 之间")
	public String getDirection() {
		String str = "北";
		int i = Integer.parseInt(direction);
		if (i < 22.5||i > 337.5){
			str = "北";
		}else if (i > 22.5&&i < 67.5){
			str = "东北";
		}else if (i > 67.5&&i < 112.5){
			str = "东";
		}else if (i > 112.5&&i < 157.5){
			str = "东南";
		}else if (i > 157.5&&i < 202.5){
			str = "南";
		}else if (i > 202.5&&i < 247.5){
			str = "西南";
		}else if (i > 247.5&&i < 292.5){
			str = "西";
		}else if (i > 292.5&&i < 337.5){
			str = "西北";
		}
		return str;
	}


	public String getDirectionNum() {
		return this.direction;
	}

	public void setDirection(String direction) {
		this.direction = direction;
	}
	
	@Length(min=0, max=64, message="报警位状态长度必须介于 0 和 64 之间")
	public String getAlarmStatus() {
		return alarmStatus;
	}

	public void setAlarmStatus(String alarmStatus) {
		this.alarmStatus = alarmStatus;
	}
	
	@Length(min=0, max=64, message="里程长度必须介于 0 和 64 之间")
	public String getMileage() {
		return mileage;
	}

	public void setMileage(String mileage) {
		this.mileage = mileage;
	}
	
	@Length(min=0, max=64, message="油量长度必须介于 0 和 64 之间")
	public String getOilNum() {
		return oilNum;
	}

	public void setOilNum(String oilNum) {
		this.oilNum = oilNum;
	}
	
	@Length(min=0, max=64, message="海拔长度必须介于 0 和 64 之间")
	public String getAltitude() {
		return altitude;
	}

	public void setAltitude(String altitude) {
		this.altitude = altitude;
	}
	
	@Length(min=0, max=64, message="状态长度必须介于 0 和 64 之间")
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getSendTime() {
		return sendTime;
	}

	public String getSendTimeStr() {
		return DateUtils.formatDateTime(sendTime);
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}
	
}